﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmVentas.aspx.cs" Inherits="WEB.frmVentas" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
	<div class="span12">
		<div class="span8">
			<div class="panel panel-info">
				<div class="panel-heading">
					<h3><b/>Información de la Venta</h3>
				</div>
				<div class="panel-body">
					
					<asp:UpdatePanel runat="server" ID="upClientes">
						<ContentTemplate>
							<table>
								<tr>
									<td><label>RUC/DNI:</label></td>
									<td><asp:TextBox ID="txtRuc" placeholder="RUC/DNI" runat="server"/></td>
									<td><asp:Button runat="server" Text="..." ID="btnBuscarCliente" CssClass="btn btn-success btn-sm" OnClick="btnBuscarCliente_Click"/></td><td> </td><td> </td><td></td><td></td><td></td>
									<td><label>N° Venta:</label></td>
									<td><asp:TextBox ID="txtCodigo" placeholder="00102" runat="server" ReadOnly="True"/></td>
								</tr>
								<tr>
									<td><label>Cliente:</label></td>
									<td><asp:TextBox ID="txtCliente" ReadOnly="True" runat="server"/></td>
									<td> </td><td> </td><td> </td><td></td><td></td><td></td>
									<td><label>Fecha:</label></td>
									<td>
										<asp:TextBox runat="server" ReadOnly="True" ID="txtFecha"></asp:TextBox>
									</td>
								</tr>
								<tr>
									<td><label>Dirección:</label></td>
									<td><asp:TextBox ID="txtDireccion" ReadOnly="True" runat="server"/></td>
									<td> </td><td> </td><td> </td><td></td><td></td><td></td>
								</tr>
							</table>
						</ContentTemplate>
						<Triggers>
							<asp:AsyncPostBackTrigger ControlID="btnBuscarCliente" EventName="Click"/>
						</Triggers>
					</asp:UpdatePanel>

					<br/><br/>
					<table>
						<tr>
							<td><label>Criterio:</label></td>
							<td><asp:TextBox ID="txtCriterio" placeholder="Buscar" runat="server"/></td>
							<td><asp:Button runat="server" CssClass="btn btn-primary btn-sm" Text="Buscar" ID="btnBuscar"/></td>
						</tr>
					 </table>
					<br/><br/>
					
					<asp:UpdatePanel runat="server" ID="upProducto">
						<ContentTemplate>
							<asp:ListView ID="lvProductos"
								 ItemType="Box.Entities.Producto" SelectMethod="GetProductos"
								runat="server" OnItemCommand="lvProductos_ItemCommand">
								<EmptyDataTemplate>
									<b>No se han encontrado Productos..!!</b>
								</EmptyDataTemplate>
								<LayoutTemplate>
									<table class="table table-bordered table-striped table-hover table-condensed">
										<thead>
											<tr>
												<th>#</th>
												<th>Descripción</th>
												
												<th>Precio</th>
												<th>Stock</th>
												<th>Acciones</th>
											</tr>
										</thead>
										<tbody>
											<tr id="itemPlaceholder" runat="server"/>
										</tbody>
									 </table>
									<asp:DataPager ID="dpProductos" PagedControlID="lvProductos" runat="server" PageSize="2">
										<Fields>
											<asp:NextPreviousPagerField
												ButtonType="Link"
												ShowFirstPageButton="True"
												ShowLastPageButton="True"
												ShowNextPageButton="True"
												ShowPreviousPageButton="True"
												/>
										</Fields>
									</asp:DataPager>
								</LayoutTemplate>
								<ItemTemplate>
									<tr>
										<th><%# Item.Id %></th>
										<th><%# Item.NombreProducto %></th>
										
										<th><%# Item.Precio %></th>
										<th><%# Item.TallaProducto %></th>
										<th>
											<asp:Button ID="btnAgregar"
												Text="Agregar" CommandName="AddDetalle"
												CommandArgument="<%# Item.Id %>"
												CssClass="btn btn-info btn-sm" runat="server"/>
										</th>
									</tr>
								</ItemTemplate>
							</asp:ListView>
						</ContentTemplate>
						<Triggers>
							<asp:AsyncPostBackTrigger ControlID="btnBuscar" EventName="Click"/>                            
						</Triggers>
					</asp:UpdatePanel>
							
							
							
						
						<legend>Detalle Venta</legend>
					 
							
							<asp:UpdatePanel runat="server" ID="upDetalle">
								<ContentTemplate>
									<asp:ListView ID="lvDetalleVenta" runat="server" OnItemCommand="lvDetalleVenta_ItemCommand">
										<EmptyDataTemplate>
											<table class="table table-bordered table-striped table-hover table-condensed">
												<thead>
													<tr>
														<th>#</th>
														<th>Descripcion</th>
														<th>Cantidad</th>
														<th>Precio</th>
														<th>Monto</th>
														<th>Acciones</th>
													</tr>
												</thead>
												<tbody>
													<tr>
														<td colspan="6">
															<h3>No tiene productos agregados a su detalle..!!</h3>
														</td>
													</tr>
												</tbody>
												<tfoot>
													<tr>
														<td></td>
														<td></td>
														<td></td>
														<td></td>
														<td></td>
														<td></td>
													</tr>
												</tfoot>
											</table>
										</EmptyDataTemplate>
										<LayoutTemplate>
											<table class="table table-bordered table-striped table-hover table-condensed">
												<thead>
													<tr>
														<th style="width: 20px;">#</th>
														<th>Descripcion</th>
														<th>Cantidad</th>
														<th>Precio</th>
														<th>Monto</th>
														<th>Acciones</th>
													</tr>
												</thead>
												<tbody>
													<tr id="itemPlaceholder" runat="server"/>
												</tbody>
												<tfoot>
													<tr>
														<td>
															<asp:Button runat="server"
																ID="btnActualizarDetalle"
																Text="Actualizar Detalle"
																CommandName="ActualizarDetalle" />
														</td>
														<td></td>
														<td></td>
														<td><h3>Total:</h3></td>
														<td><h3><asp:Label ID="lblTotal" runat="server"></asp:Label></h3></td>
														<td></td>
													</tr>
												</tfoot>
											</table>
										</LayoutTemplate>                                
										<ItemTemplate>
											<tr>
												<td><%# Eval("Producto.Id") %></td>
												<td><%# Eval("Producto.NombreProducto") %></td>
												<td><asp:TextBox runat="server" ID="txtCantidad" Text='<%# Bind("Cantidad") %>' Width="50px"/></td>
												<td><asp:TextBox runat="server" ID="txtPrecio" Text='<%# Bind("PrecioUnit") %>' Width="50px"/></td>
												<td><%# Eval("Monto") %></td>
												<td>
													<asp:Button runat="server" Text="Quitar"
														CssClass="btn btn-danger btn-sm"
														CommandName="QuitarDetalle"
														CommandArgument='<%# Eval("IdProducto") %>'/>
												</td>
											</tr>
										</ItemTemplate>
									</asp:ListView>
								</ContentTemplate>
								<Triggers>
									<asp:AsyncPostBackTrigger ControlID="lvDetalleVenta" EventName="ItemCommand"/>
									<asp:AsyncPostBackTrigger ControlID="lvProductos" EventName="ItemCommand"/>
									<asp:AsyncPostBackTrigger ControlID="btnGuardar" EventName="Click"/>
								</Triggers>
							</asp:UpdatePanel>
							

							
						
				</div>
				<div class="panel-footer">
					<asp:Button runat="server" ID="btnGuardar" CssClass="btn btn-success" Text="Guardar" OnClick="btnGuardar_Click"/>
					  <%-- <asp:Button runat="server" ID="btnLimpiar" CssClass="btn bg-info" Text="Limpiar"/>--%>
					 <asp:Button ID="Button7" runat="server" Text="Cancelar" CssClass="btn btn-danger"/>
				</div>
			</div>
		</div>
	</div>
	 
	
	
</asp:Content>
